<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="./09_tets.js"></script>
<body>
    <script>
        //  Promise.resolve()缓存后台数据
        //  Promise.resolve("唐玮").then(value=>{
        //      console.log(value);
        //  })

        function quary(name){
            const cache=quary.cache || (quary.cache=new Map());//定义一个缓存map

            if(cache.has(name)){
                console.log("走缓存了");
                return Promise.resolve(cache.get(name)).then(value=>console.log(value));
            }
            else{
                (new data).show().then(value=>{
                     cache.set(value[0],value[1]);
                     console.log("没有走缓存");
                     console.log(value);
                 });
            }
        }
    setInterval(()=>{
        quary("555");
    },3000);
    </script>
</body>
</html>